﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
@* <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script> *@
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>IMES</title>

    <link href="~/hiprint/css/hiprint.css" rel="stylesheet" />
    <link href="~/hiprint/css/print-lock.css" rel="stylesheet" />
    @*hiprint的所有javascript插件都依赖于jQuery，所以请在使用前先引入jQuery。 *@
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    @* polyfill.min.js解决浏览器兼容性问题 *@
    <script src="~/hiprint/polyfill.min.js"></script>
    @*hiprint 核心js *@
    <script src="~/hiprint/hiprint.bundle.js"></script>
    @* 条形码生成组件 *@
    <script src="~/hiprint/plugins/jsbarcode.all.min.js"></script>
    @* 二维码生成组件 *@
    <script src="~/hiprint/plugins/qrcode.js"></script>
    @* 调用浏览器打印窗口helper类，可自行替换 *@
    <script src="~/hiprint/plugins/jquery.hiwprint.js"></script>
</head>
<body>
    <div id="templateDesignDiv"></div>
    <script>
        $(function () {
            print();
            PrintThis()
        })
        hiprint.init();
        var hiprintTemplate;
        var obj = {
            "panels": [{ "index": 0, "paperType": "A4", "height": 297, "width": 210, "paperHeader": 43.5, "paperFooter": 801, "printElements": [{ "options": { "left": 228, "top": 18, "height": 9.75, "width": 120, "title": "销售订单表", "fontSize": 19.5, "fontWeight": "900", "textAlign": "center", "textContentVerticalAlign": "middle" }, "printElementType": { "type": "text" } }, { "options": { "left": 489, "top": 19.5, "height": 90, "width": 120, "title": "xdzcbggvxzc ", "textType": "qrcode", "barcodeMode": "UPC（A）" }, "printElementType": { "type": "text" } }, { "options": { "left": 18, "top": 45, "height": 55.5, "width": 64.5, "src": "/Content/assets/hi.png" }, "printElementType": { "type": "image" } }, { "options": { "left": 18, "top": 111, "height": 9.75, "width": 259.5, "title": "订单编号", "field": "orderNo", "fontSize": 14.25, "fontWeight": "500" }, "printElementType": { "type": "text" } }, { "options": { "left": 190.5, "top": 159, "height": 9.75, "width": 280.5, "title": "创建时间", "field": "createDate", "fontSize": 14.25 }, "printElementType": { "type": "text" } }, { "options": { "left": 31.5, "top": 159, "height": 9.75, "width": 103.5, "title": "制单人", "field": "createName", "fontSize": 14.25 }, "printElementType": { "type": "text" } }, { "options": { "left": 196.5, "top": 192, "height": 36, "width": 178.5, "field": "productNumber", "textAlign": "center", "tableHeaderFontSize": 12, "columns": [[{ "title": "产品编号", "width": 178.5, "colspan": 1, "rowspan": 1, "checked": true }]] }, "printElementType": { "title": "表格", "type": "tableCustom" } }, { "options": { "left": 375, "top": 192, "height": 36, "width": 201, "field": "productNum", "textAlign": "center", "tableHeaderFontSize": 12, "columns": [[{ "title": "数量", "field": "", "width": 201, "colspan": 1, "rowspan": 1, "checked": true }]] }, "printElementType": { "title": "表格", "type": "tableCustom" } }, { "options": { "left": 18, "top": 192, "height": 36, "width": 178.5, "field": "productName", "textAlign": "center", "tableHeaderFontSize": 12, "columns": [[{ "title": "产品名称", "field": "", "width": 178.5, "colspan": 1, "rowspan": 1, "checked": true }]] }, "printElementType": { "title": "表格", "type": "tableCustom" } }], "paperNumberLeft": 565, "paperNumberTop": 819 }]
        }


        //打印设计
        hiprintTemplate = new hiprint.PrintTemplate({
            template: obj,
        });
        hiprintTemplate.design('#templateDesignDiv', { grid: true });
        function print() {
            console.log(999, obj)
            var thisNo = location.href.split("=")[1];
            console.log(thisNo)
            $.ajax({
                url: '@ViewBag.Darius' + '/api/Orders/GetOrderPro',
                data: JSON.stringify({ orderId: thisNo }),
                type: 'post',
                contentType: 'application/json',
                dataType: 'json',
                success: function (res) {
                    console.log(888, res)
                    if (res.data1 != null) {
 
                    }
                }
            });
            $("#templateDesignDiv").empty();
        }

        function PrintThis() {
            var thisNo = location.href.split("=")[1];
            console.log(thisNo)
            $.ajax({
                url: '@ViewBag.Darius' + '/api/Orders/GetOrderPro',
                data: JSON.stringify({ orderId: thisNo }),
                type: 'post',
                contentType: 'application/json',
                dataType: 'json',
                success: function (res) {
                    console.log(777, res)
                    if (res.data1 != null) {
                        res.data1.createDate = res.data1.createDate.split("T")[0];
                        hiprintTemplate.print(res.data1);
                    }
                }
            });
        }

    </script>
</body>
</html>
